#ifndef ROOMMANAGER_H
#define ROOMMANAGER_H

#include <QObject>
class Signaling;
class JanusPeerConnection;
class RemoteMediaStream;

#include "rtc_base/ref_counted_object.h"
#include "api/scoped_refptr.h"

class RoomManager : public QObject
{
    Q_OBJECT
public:
    explicit RoomManager(QObject *parent = nullptr);
    virtual ~RoomManager();

    void init();

    void connectToServer(const QString& strUrl);


Q_SIGNALS:

public Q_SLOTS:
    /**
     * @brief slotConnected 链接服务器成功
     */
    void slotConnected();

private:
    /**
     * @brief createSessionID 创建会话ID
     */
    void createSessionID();

    /**
     * @brief onCreateSessionID  信令服务器创建会话返回信息
     * @param recvData json信息
     */
    void onCreateSessionID(const QJsonObject& recvData);

    void onEventJoin(const QJsonObject& recvData);
    void onEventEvent(const QJsonObject& recvData);
    void ontEventAttached(const QJsonObject& recvData);

    void onEventPublish(const QJsonObject& recvData);
    void onEventUnPublish(const QJsonObject& recvData);

    void peerConnect(const qint64& peerID, JanusPeerConnection* peer);


private:
    qint64                                          m_seesionID;
    qint64                                          m_privateID;
    QString                                         m_strOpaqueID;
    Signaling                                       *m_pSignalHelper;

    QList<JanusPeerConnection*>                     m_peerList;
    QList<rtc::scoped_refptr<RemoteMediaStream>>    m_remoteStreamList;

};

#endif // ROOMMANAGER_H
